﻿<Window x:Class="Citrix.XaAdminMobile.PopupWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:cmp="clr-namespace:Citrix.Cmp;assembly=Citrix.Cmp.WPF"
        xmlns:vm="clr-namespace:Citrix.XaAdminMobile.ViewModel"
        AllowsTransparency="True" Background="Transparent" WindowStyle="None"
        cmp:AutoWindowLayout.LayoutEnabled="True"
        cmp:AutoWindowLayout.DpiScalingEnabled="True"
        cmp:AutoWindowLayout.FallbackWindowStyle="None"
        Title="XenApp Admin Mobile Popup" Height="300" Width="300">
  <Window.Resources>

    <Style x:Key="GlassButtonStyle" TargetType="{x:Type Button}">
      <Setter Property="SnapsToDevicePixels" Value="True"/>
      <Setter Property="OverridesDefaultStyle" Value="True"/>
      <Setter Property="FontWeight" Value="Bold"/>
      <Setter Property="FontSize" Value="14"/>
      <Setter Property="Foreground" Value="White"/>
      <Setter Property="Background" Value="#7F000000"/>
      <Setter Property="FocusVisualStyle" Value="{x:Null}"/>
      <Setter Property="Padding" Value="5"/>
      <Setter Property="Template">
        <Setter.Value>
          <ControlTemplate TargetType="{x:Type Button}">
            <Border Background="{TemplateBinding Background}" CornerRadius="8"
                  BorderBrush="Black" BorderThickness="3">
              <Grid>
                <Grid.RowDefinitions>
                  <RowDefinition Height="*"/>
                  <RowDefinition Height="*"/>
                </Grid.RowDefinitions>

                <Border Grid.Row="0" HorizontalAlignment="Stretch" Opacity="0.8" CornerRadius="8,8,0,0">
                  <Border.Background>
                    <LinearGradientBrush EndPoint="0.494,0.889" StartPoint="0.494,0.028">
                      <GradientStop Color="#99FFFFFF" Offset="0"/>
                      <GradientStop Color="#33FFFFFF" Offset="1"/>
                    </LinearGradientBrush>
                  </Border.Background>
                </Border>

                <ContentPresenter Grid.RowSpan="2" Margin="{TemplateBinding Padding}"
                                HorizontalAlignment="Center" VerticalAlignment="Center" />

                <!-- Animation target to provide a press highlight. -->
                <Border x:Name="PressHighlight" Grid.RowSpan="2" BorderBrush="Black" BorderThickness="0"
                      CornerRadius="4"/>

              </Grid>
            </Border>
            <ControlTemplate.Triggers>
              <Trigger Property="IsPressed" Value="true">
                <Trigger.EnterActions>
                  <BeginStoryboard>
                    <Storyboard>
                      <ThicknessAnimation
                      Storyboard.TargetName="PressHighlight"
                      Storyboard.TargetProperty="BorderThickness"
                      From="0"
                      To="2"
                      Duration="0:0:0.03">
                      </ThicknessAnimation>
                    </Storyboard>
                  </BeginStoryboard>
                </Trigger.EnterActions>
                <Trigger.ExitActions>
                  <BeginStoryboard>
                    <Storyboard>
                      <ThicknessAnimation
                      Storyboard.TargetName="PressHighlight"
                      Storyboard.TargetProperty="BorderThickness"
                      To="0"
                      BeginTime="0:0:0.0"
                      Duration="0:0:0.06">
                      </ThicknessAnimation>
                    </Storyboard>
                  </BeginStoryboard>
                </Trigger.ExitActions>
              </Trigger>
            </ControlTemplate.Triggers>
          </ControlTemplate>
        </Setter.Value>
      </Setter>
    </Style>

    <DataTemplate DataType="{x:Type vm:PopupMessageViewModel}">
      <TextBlock Text="{Binding Message}" FontSize="{Binding FontSize}"
                FontWeight="{Binding FontWeight}"
                Foreground="White" Margin="0,10"
                TextAlignment="{Binding Alignment}" TextWrapping="Wrap"/>
    </DataTemplate>

    <DataTemplate DataType="{x:Type vm:PopupButtonViewModel}">
      <Button Command="{Binding PopupCommand}" Style="{DynamicResource GlassButtonStyle}"
            Content="{Binding PopupLabel}" Padding="8"
            Background="{Binding BackgroundBrush}" Foreground="{Binding ForegroundBrush}"
            FontSize="18" Margin="0,5"
            MaxWidth="300"/>
    </DataTemplate>

  </Window.Resources>

  <Grid>

    <Grid.RowDefinitions>
      <RowDefinition Height="*"/>
      <RowDefinition Height="Auto"/>
      <RowDefinition Height="*"/>
    </Grid.RowDefinitions>

    <Grid.ColumnDefinitions>
      <ColumnDefinition Width="1*"/>
      <ColumnDefinition Width="8*" MaxWidth="600"/>
      <ColumnDefinition Width="1*"/>
    </Grid.ColumnDefinitions>

    <!-- Cover full window area to ensure we capture all hit testing. -->
    <Rectangle Grid.RowSpan="3" Grid.ColumnSpan="3" Fill="Transparent" />

    <!-- The primary content panel. Holds the list of popup items as well as giving them a dark
        background. -->
    <Border Grid.Row="1" Grid.Column="1" BorderBrush="#E83F3F3F"
              CornerRadius="10" BorderThickness="2">
      <Border Background="#E83F3F3F" CornerRadius="10"
                BorderBrush="White" BorderThickness="3">
        <Grid Margin="0,15" Grid.RowSpan="2">
          <Grid.ColumnDefinitions>
            <!-- Left margin -->
            <ColumnDefinition Width="10*"/>
            <!-- Popup items -->
            <ColumnDefinition Width="70*"/>
            <!-- Right margin -->
            <ColumnDefinition Width="10*"/>
          </Grid.ColumnDefinitions>

          <ItemsControl Grid.Column="1" VerticalAlignment="Bottom"
                          ItemsSource="{Binding PopupItems}" />
        </Grid>
      </Border>
    </Border>
  </Grid>
  
</Window>
